package com.bush.mall.coupon.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.coupon.entity.HomeAdvEntity;
import com.bush.mall.coupon.service.HomeAdvService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 首页轮播广告
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("homeadv")
@Api(tags = "首页轮播广告管理" )
public class HomeAdvController {

    @Resource(name= HomeAdvService.BEAN_ID)
    private HomeAdvService homeAdvService;

    /**
     * 分页查询首页轮播广告列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询首页轮播广告列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return homeAdvService.queryForPage(current,size);
    }

    /**
     * 保存首页轮播广告表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存首页轮播广告表单")
    @PostMapping
    public Result saveHomeAdv(@RequestBody HomeAdvEntity homeAdv){
        return homeAdvService.saveHomeAdv(homeAdv);
    }

    /**
     * 修改首页轮播广告表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改首页轮播广告表单")
    @PutMapping
    public Result updateHomeAdv(@RequestBody HomeAdvEntity homeAdv){
        return homeAdvService.updateHomeAdv(homeAdv);
    }

    /**
     * 通过指定id删除首页轮播广告
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除首页轮播广告")
    @DeleteMapping
    public Result deleteHomeAdv(Long id){
        return homeAdvService.deleteHomeAdv(id);
    }

}
